package com.kly.user.task.enums;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author linqu
 */
public enum TaskStatusEnum {

    INIT(0, "INIT"),
    SUCCESS(1, "SUCCESS"),
    FAILED(2, "FAILED"),
    /**
     * review数据需要手工check后，没有问题再进行推送
     */
    REVIEW(9, "REVIE"),
    ;


    private Integer code;
    private String name;

    TaskStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public TaskStatusEnum setCode(Integer code) {
        this.code = code;
        return this;
    }

    public String getName() {
        return name;
    }

    public TaskStatusEnum setName(String name) {
        this.name = name;
        return this;
    }

    public static TaskStatusEnum getEnumByCode(Integer code) {

        if (Objects.isNull(code)) {
            return null;
        }

        TaskStatusEnum TaskTypeEnum = null;

        for (TaskStatusEnum p : TaskStatusEnum.values()) {
            if (p.getCode().equals(code)) {
                TaskTypeEnum = p;
            }
        }
        return TaskTypeEnum;
    }


    public static List<TaskStatusEnum> getPaymentChannelEnumList() {
        List<TaskStatusEnum> payGatewayEnumList = new ArrayList<>();

        for (TaskStatusEnum paymentChannelEnum : TaskStatusEnum.values()) {
            payGatewayEnumList.add(paymentChannelEnum);
        }

        return payGatewayEnumList;
    }
}
